<template>
  <div class="SinglesPage">
    <div class="header">
      <img src="@assets/images/superSale/header.png" alt="" />
    </div>
    <div v-for="oneList in goodsList" :key="oneList.id" class="father">
      <div class="goodsList">
        <div class="dis">
          {{ oneList.header }}
        </div>
        <div class="listDivBig" v-if="oneList.listDivBig.length > 0">
          <img
            @click="toDetail(img.id)"
            v-for="img in oneList.listDivBig"
            :key="img.id"
            v-lazy="img.url"
            alt=""
          />
        </div>
        <div class="listDivSmall" v-if="oneList.listDivSmall.length > 0">
          <img
            @click="toDetail(img.id)"
            v-for="img in oneList.listDivSmall"
            :key="img.id"
            v-lazy="img.url"
            alt=""
          />
        </div>
        <!-- <div class="lookmore" v-show="oneList.type == '2'">
                <p @click="toSalePage">更多特惠</p>
                <img @click="toSalePage" src="@assets/images/superSale/more.png" alt="" srcset="">
            </div> -->
      </div>
    </div>

    <div style="height: 1.36rem;"></div>
    <div class="bottomDiv1">
      <div class="bottomDiv">
        <div class="bg" @click="toListPage()">
          <p>发现更多超值商品</p>
          <img
            :style="{ transform: 'translate(' + deg + 'px)' }"
            class="go"
            src="@assets/images/superSale/GO.png"
            alt=""
          />
          <img class="jian" src="@assets/images/superSale/goNext.png" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Recommend from "@components/Recommend";
import cookie from "@utils/store/cookie";
import debounce from "lodash.debounce";
import share from "../../assets/js/common/share.js";
import shareMsg from "../../assets/js/common/shareConfig.js";
const CHECKED_IDS = "cart_checked";

export default {
  name: "SinglesPage",
  components: {
    Recommend
  },
  props: {},
  data: function() {
    return {
      deg: "0",
      from1: "h5",
      goodsList: [
        {
          header: "0元秒杀",
          type: "1",
          listDivBig: [],
          listDivSmall: [
            {
              url: require("@assets/images/superSale/freeBuy7.png"),
              id: "550"
            },
            {
              url: require("@assets/images/superSale/freeBuy8.png"),
              id: "547"
            },
            {
              url: require("@assets/images/superSale/freeBuy9.png"),
              id: "408"
            },
            {
              url: require("@assets/images/superSale/freeBuy10.png"),
              id: "404"
            },
            {
              url: require("@assets/images/superSale/freeBuy11.png"),
              id: "491"
            },
            {
              url: require("@assets/images/superSale/freeBuy12.png"),
              id: "546"
            },
            {
              url: require("@assets/images/superSale/freeBuy1.png"),
              id: "114"
            },
            {
              url: require("@assets/images/superSale/freeBuy2.png"),
              id: "379"
            },
            {
              url: require("@assets/images/superSale/freeBuy3.png"),
              id: "120"
            },
            {
              url: require("@assets/images/superSale/freeBuy4.png"),
              id: "121"
            },
            {
              url: require("@assets/images/superSale/freeBuy5.png"),
              id: "287"
            },
            {
              url: require("@assets/images/superSale/freeBuy6.png"),
              id: "288"
            }
          ]
        },
        {
          header: "限量特惠",
          type: "2",
          listDivBig: [],
          listDivSmall: [
            {
              url: require("@assets/images/superSale/limit1.png"),
              id: "113"
            },
            {
              url: require("@assets/images/superSale/limit2.png"),
              id: "327"
            },
            {
              url: require("@assets/images/superSale/limit3.png"),
              id: "326"
            },
            {
              url: require("@assets/images/superSale/limit4.png"),
              id: "310"
            },
            {
              url: require("@assets/images/superSale/limit5.png"),
              id: "305"
            },
            {
              url: require("@assets/images/superSale/limit6.png"),
              id: "45"
            }
          ]
        },
        {
          header: "首单立减",
          type: "1",
          listDivBig: [
            {
              url: require("@assets/images/superSale/first1.png"),
              id: "369"
            },
            {
              url: require("@assets/images/superSale/first2.png"),
              id: "363"
            },
            {
              url: require("@assets/images/superSale/first3.png"),
              id: "362"
            },
            {
              url: require("@assets/images/superSale/first4.png"),
              id: "361"
            },
            {
              url: require("@assets/images/superSale/first5.png"),
              id: "62"
            },
            {
              url: require("@assets/images/superSale/first6.png"),
              id: "58"
            }
          ],
          listDivSmall: []
        }
      ]
    };
  },
  watch: {},
  mounted: function() {
    if (this.$route.query.isToken) {
      this.$store.commit(
        "LOGIN",
        this.$route.query.isToken
        // dayjs(expires_time) - newTime
      );
      cookie.set("OID", this.$route.query.oId);
    }
    var shareUrl1 = window.location.href.split("?")[0];
    if (this.$route.query.from1 == "app") {
      shareMsg.shareConfig(
        "app",
        "0",
        "0",
        "听见年货节",
        "听见广播",
        shareUrl1,
        "https://seefm.oss-cn-beijing.aliyuncs.com/image/icon.png",
        "",
        "1"
      );
    }
    share.share(
      shareUrl1,
      "听见年货节",
      "听见广播",
      "https://seefm.oss-cn-beijing.aliyuncs.com/image/icon.png"
    );
    share.QQshare(
      shareUrl1,
      "听见年货节",
      "听见广播",
      "https://seefm.oss-cn-beijing.aliyuncs.com/image/icon.png"
    );
  },
  created() {
    if (this.$route.query.from1) {
      this.from1 = this.$route.query.from1;
    }
    cookie.set("from1", this.from1);
    this.changeDeg();
    if (this.from1 == "app") {
      this.getTitle();
    }
  },
  methods: {
    changeDeg: function() {
      setInterval(() => {
        if (this.deg == "0") {
          this.deg = "5";
        } else {
          this.deg = "0";
        }
      }, 500);
    },

    toDetail: function(id) {
      if (this.from1 == "app") {
        this.$router.push({
          path: "/detail/" + id + "?mer_id=5070770&from1=" + this.from1
        });
      } else {
        this.$router.push({
          path: "/detail/" + id + "?mer_id=5070770"
        });
      }
    },
    toListPage: function() {
      if (this.from1 == "app") {
        this.$router.push({
          path: "/goods_list/5070770?from1=" + this.from1 + "&isshowTui=1"
        });
      } else {
        this.$router.push({
          path: "/goods_list/5070770?isshowTui=1"
        });
      }
    },
    toSalePage: function() {
      if (this.from1 == "app") {
        this.$router.push({
          path: "/goods_list/5058293?from1=" + this.from1
        });
      } else {
        this.$router.push({
          path: "/goods_list/5058293"
        });
      }
    },

    getTitle: function() {
      var self = this;
      var u = navigator.userAgent,
        app = navigator.appVersion;
      var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Linux") > -1; //g
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
      var obj = {
        action: "setTitle",
        content: {
          title: "听见年货节"
        }
      };
      if (isAndroid) {
        App.onAppResponse(JSON.stringify(obj));
      }
    }
  }
};
</script>
<style scoped>
.SinglesPage {
  width: 100%;
  min-height: 100vh;
  height: auto;
  background: rgba(180, 0, 2, 1);
  overflow: hidden;
}
.SinglesPage .header {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 4.98rem;
  margin-bottom: -1.66rem;
}
.SinglesPage .header img {
  display: block;
  width: 100%;
  height: 100%;
}
.father {
  box-sizing: border-box;
  background-image: linear-gradient(
    180deg,
    rgba(255, 226, 191, 1),
    rgba(255, 229, 160, 0.16)
  );
  border-radius: 0.08rem;
  padding: 0.03rem;
  margin-bottom: 0.3rem;
  position: relative;
  z-index: 2;
  margin: 0 0.12rem;
}
.SinglesPage .goodsList {
  width: 7.21rem;
  height: auto;
  background: linear-gradient(180deg, #eb3018 0%, rgba(223, 37, 37, 0.93) 100%);
  border-radius: 0.08rem;
  /* border-radius: 0.08rem;
        border: 0.03rem solid; */
  /* border-image: linear-gradient(180deg, rgba(255, 226, 191, 1), rgba(255, 229, 160, 0.16)) 3 3; */
}
.SinglesPage .goodsList .lookmore {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 0.26rem;
  padding-bottom: 0.26rem;
}
.SinglesPage .goodsList .lookmore p {
  font-size: 0.28rem;
  font-weight: 600;
  color: #ffffff;
  line-height: 0.4rem;
  margin: 0 0.08rem 0 2.92rem;
}
.SinglesPage .goodsList .lookmore img {
  width: 0.2rem;
}
.SinglesPage .dis {
  text-align: center;
  font-size: 0.32rem;
  font-weight: 600;
  color: #763205;
  line-height: 1;
  padding: 0.12rem 0;
  width: 3.36rem;
  margin-left: 1.93rem;
  margin-bottom: 0.16rem;
  height: auto;
  background: linear-gradient(180deg, #ffdfb8 0%, #ffb53c 100%);
  border-radius: 0px 0px 0.22rem 0.22rem;
  box-sizing: border-box;
}
.SinglesPage .dis img {
  /* margin-top: 0.16rem; */
  width: 100%;
  height: 100%;
  display: block;
}
.SinglesPage .listDivSmall {
  width: 6.92rem;
  margin: 0 0.14rem 0.08rem 0.14rem;
  display: flex;
  box-sizing: border-box;
  display: -webkit-flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
  height: auto;
  padding-bottom: 0.2rem;
}
.SinglesPage .listDivSmall img {
  width: 2.26rem;
  height: 3.6rem;
  margin-bottom: 0.08rem;
}
.SinglesPage .listDivBig {
  width: 6.96rem;
  margin: 0 0.13rem 0.04rem 0.11rem;
  display: flex;
  display: -webkit-flex;
  justify-content: space-between;
  flex-direction: row;
  flex-wrap: wrap;
  height: auto;
}
.SinglesPage .listDivBig img {
  width: 3.44rem;
  height: 4.92rem;
  margin-bottom: 0.08rem;
}
.SinglesPage .bottomDiv1 {
  bottom: 0;
  position: fixed;
  z-index: 3;
  width: 100%;
  height: 1.36rem;
  background: #9c0000;
}
.SinglesPage .bottomDiv1 .bottomDiv {
  width: 100%;
  height: 1.36rem;
  display: flex;
  justify-content: flex-start;
}
.SinglesPage .bottomDiv .bg {
  height: 0.84rem;
  display: flex;
  justify-content: flex-start;
  width: 6.48rem;
  margin: 0.24rem 0.5rem 0.24rem 0.51rem;
  background: linear-gradient(180deg, #ffdfb8 0%, #ffb53c 100%);
  border-radius: 0.44rem;
}
.SinglesPage .bottomDiv p {
  font-size: 0.4rem;
  font-weight: 500;
  color: rgba(118, 50, 5, 1);
  line-height: 0.56rem;
  margin: 0.16rem 0.1rem 0.16rem 1.02rem;
  font-weight: 600;
}
.SinglesPage .bottomDiv .go {
  width: 0.8rem;
  height: 0.74rem;
  margin-right: 0.1rem;
  margin-top: 0.08rem;
}
.SinglesPage .bottomDiv .jian {
  width: 0.32rem;
  height: 0.32rem;
  margin-right: 0.86rem;
  margin-top: 0.28rem;
}
</style>
